/**
 * Copyright (c) 2016-2019 人人开源 All rights reserved.
 *
 * https://www.renren.io
 *
 * 版权所有，侵权必究！
 */

package io.renren.modules.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.R;
import io.renren.modules.app.dao.UserTokenDao;
import io.renren.modules.app.entity.UserTokenEntity;
import io.renren.modules.app.oauth3.TokenGenerator;
import io.renren.modules.app.service.UserTokenService;
import io.renren.modules.app.utils.JwtUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;


@Service("UserTokenService")
public class UserTokenServiceImpl extends ServiceImpl<UserTokenDao, UserTokenEntity> implements UserTokenService {

	@Autowired
	private JwtUtils jwtUtils;

	@Override
	public R createToken(long userId) {
		return R.ok().put("token",jwtUtils.generateToken(userId));
	}

	@Override
	public void logout(long userId) {

	}

	@Override
    public UserTokenEntity queryByToken(String token) {
        return this.getOne(new QueryWrapper<UserTokenEntity>().eq("token",token));
    }

}
